<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui-date,auto-complete,dtvalidate,layui,chosen'}){%>
    <style type="text/css">
        body{padding-top:10px;}
        *{margin:0;padding:0;list-style-type:none;}
        a,img{border:0;}
        .demo h2{font-size:16px;color:#3366cc;height:30px;}
        .demo li{float:left;}
        .has-no{color:#3366cc;}
        .has-success{color: #1ab394;}
        .has-warning{color: #f8ac59;}
        .has-error{color: #ed5565;}
        .has-receive{color: #9E792E;}
        .remark {
            width: 100%; /*自动适应父布局宽度*/
            overflow: auto;
            word-break: break-all;
        }
    </style>
    <%}%>
</head>

<body>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-content" style="padding:15px 20px 0px 20px;">
                <form id="search-form" role="form" class="form-horizontal" autocomplete="off">
                    <input type="hidden" readonly id="produceMember" name="produceMember" class="form-control" value="${user.userRealname}">
                    <div class="form-group">
                        <label class="control-label col-sm-1">状态:</label>
                        <div class="col-sm-2">
                            <select  name="produceStatus" id="produceStatus" class="form-control">
                                <option value="">全部分类</option>
                                <option value="1">待审核</option>
                                <option value="2">审核中</option>
                                <option value="3">审核通过</option>
                                <option value="4">拒绝</option>
                                <option value="5">废弃</option>
                                <option value="31">部分收货</option>
                                <option value="32">全部收货</option>
                                <option value="33">手工关闭</option>
                            </select>
                        </div>
                        <label class="control-label col-sm-1">供应商:</label>
                        <div class="col-sm-2">
                            <input type="text" id="produceSupplierName" name="produceSupplierName" class="form-control">
                        </div>
                        <label class="control-label col-sm-1">PO号:</label>
                        <div class="col-sm-2">
                            <input type="text" id="produceNo" name="produceNo" class="form-control">
                        </div>
                        <label class="control-label col-sm-1">SKU:</label>
                        <div class="col-sm-2">
                            <input type="text" id="orderSku" name="orderSku" class="form-control">
                        </div>
                        <a class="search-btn btn btn-success" style="margin-bottom: 0px;">查询</a>
                    </div>

                </form>
            </div>
            <div id="toolbar" class="btn-group" style="margin-bottom:5px;">
                <button  class="layui-btn layui-btn-sm import-btn" style="margin-left: -2px"  id="import-btn"  name="import-btn">
                    <i class="layui-icon"></i>导入SKU变动
                </button>
                <button  class="layui-btn  layui-btn-sm" >
                    <i class="fa fa-download"></i>
                    <a href="/excel/采购单调整模板.xlsx" style="color: white" download>模板下载</a>
                </button>
            </div>

    <!-- START 数据表格 -->
    <table id="portTable"
           data-toolbar="#toolbar"
           data-side-pagination="server"
           data-pagination="true"
           data-resizable="true"
           data-url="/sea/supply/produceBalance/findByCnd.do"
           data-page-size="15"
           class="table table-striped table-hover"
    >
    </table>
        </div>
    </div>
    <!-- END 数据表格 -->
</div>



<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,bootstrap-table-zh-CN,dtvalidate,dtvalidate-lang-zh_cn,laydate,layer,layui,chosen,chosen-demo,upload'}){}%>
<script>
    laydate.render({
        elem: '#buyOrderDate' //指定元素
        ,trigger: 'click'
    });
    laydate.render({
        elem: '#beginDate' //指定元素
        ,trigger: 'click'
    });
    laydate.render({
        elem: '#endDate' //指定元素
        ,trigger: 'click'
    });

    var $portTable = $('#portTable');
    $(function(){
        //START 表格配置
        $portTable.bootstrapTable({
            pageList: [10, 15, 20, 2000],
            columns: [
                {
                    title: '采购单号',
                    field: 'produceNo',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '渠道',
                    field: 'produceSupplierName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '渠道',
                    field: 'orderChannelName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: 'SKU',
                    field: 'orderSku',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '预计交期',
                    field: 'orderDate',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '修改前数量',
                    field: 'produceBeforeNumber',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '修改后数量',
                    field: 'produceAfterNumber',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '修改人',
                    field: 'produceMember',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '创建时间',
                    field: 'createTime',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r) {
                        if (v == null) {
                            return '';
                        }
                        v = v.substr(0, 11);
                        return v;
                    }
                }
            ],
            onLoadSuccess : function(){

            }
        });


        layui.use('upload', function(){
            var upload = layui.upload;
            upload.render({
                elem: '#import-btn', //绑定元素,
                accept:'file',
                url: '/sea/supply/produceBalance/import/', //上传接口
                data:{"produceMember":$("#produceMember").val()},
                before:function () {
                    layer.load(1, {
                        shade: [0.1,'#fff'] //0.1透明度的白色背景
                    });
                }
                ,done: function(data){
                    if( data.ok ){
                        layer.msg(data.msg,{icon: 1,time: 1500},function(){
                            //刷新页面
                            $portTable.bootstrapTable('refresh');
                            layer.closeAll();
                        });
                    }else{
                        layer.msg(data.msg,{icon: 0,time: 5000},function () {
                            layer.closeAll();
                        });

                    }
                }
                ,error: function(){
                    //请求异常回调
                    layer.closeAll();
                }
            });
        });
    $('.search-btn').on('click',function(){
        $portTable.bootstrapTable('refresh', { url:'${ctxPath}/sea/supply/produceBalance/findByCnd.do?'+$('#search-form').serialize() });
    });
});
</script>
</body>
</html>
